﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace CodeStandardAddin.View
{
	public class EditorConfigControl : ConfigControl
	{
		#region Field ---------------------------------------------------------------------------------

		protected Panel leftPanel = new Panel();
		private TextEditorControl codeEditor = new TextEditorControl();

		#endregion Field ------------------------------------------------------------------------------


		#region Constructors --------------------------------------------------------------------------

		public EditorConfigControl()
		{
			leftPanel.Dock = DockStyle.Left;
			leftPanel.TabIndex = 0;
			leftPanel.Size = new Size(200, 0);
			leftPanel.Padding = new Padding(0, 0, 3, 0);

			codeEditor.BorderStyle = BorderStyle.FixedSingle;
			codeEditor.IsReadOnly = true;
			codeEditor.Dock = DockStyle.Fill;
			codeEditor.TabIndex = 9999;

			this.Controls.Add(codeEditor);
			this.Controls.Add(leftPanel);
		}

		#endregion Constructors -----------------------------------------------------------------------


		#region Method --------------------------------------------------------------------------------

		public void SetHighlightingCode(string codeName)
		{
			codeEditor.SetHighlighting(codeName);
			codeEditor.Refresh();
		}

		#endregion Method -----------------------------------------------------------------------------


		#region Properties ----------------------------------------------------------------------------

		[Browsable(false)]
		public TextEditorControl Editor
		{
			get { return codeEditor; }
		}

		[EditorBrowsable(EditorBrowsableState.Always), Browsable(true)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
		[Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral", typeof(System.Drawing.Design.UITypeEditor))]
		public string EditorCode
		{
			get { return codeEditor.Text; }
			set { codeEditor.Text = value; }
		}

		#endregion Properties -------------------------------------------------------------------------
	}
}